<template>
  <div class="header-info">
    <div class="aside-logo icon_cal">
      商务管理系统
    </div>
    <span class="name-company">
      <span class="name" @click="ltdModal.open=true">苏州点控科技有限公司</span>
      <!-- <span class="name" v-if="[1].indexOf(parseInt($store.state.userInfo.role))!==-1">{{$store.state.companyInfo.companyName}}</span> -->
    </span>
    <div class="tool tool-user">
      <span class="user-card">
        <div class="styled-icon-user pic">
          {{ $store.state.userInfo.role === 1 ? "用户" : "管理员" }}
          <!-- {{ $store.state.userInfo.name || "管理员" }} -->
        </div>
        <i class="fa fa-chevron-down t-small"></i>
      </span>
      <ul class="user-nav">
        <li @click="logout">
          <i class="iconfont icon-quit"></i>
          <span>退出</span>
        </li>
      </ul>
    </div>
    <el-dialog
      title="提示"
      :visible="errorModal.open"
      width="30%"
    >
      <span>{{errorModal.msg}}</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="errorModal.open = false">取 消</el-button>
        <el-button type="primary" @click="errorModal.open = false">确 定</el-button>
      </span>
    </el-dialog>
    
    <el-dialog
      title="选择公司"
      :visible="ltdModal.open"
      width="30%"
    >
      <div class="content">
        <div>
          <ul>
            <li v-for="(item, i) in ltdList" :key="i">
              <span>{{item.name}}</span>
            </li>
          </ul>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="ltdModal.open = false">取 消</el-button>
        <el-button type="primary" @click="ltdModal.open = false">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import Store from "@/store/store.js";
export default {
  name: "i-header",
  components: {},
  mounted() {},
  data() {
    return {
      ltdList: [{
        name: '点控科技有限公司'
      },{
        name: '泰诚咨询有限公司'
      }],
      ltdModal: {
        open: false
      },
      projectSpeed: {
        open: false
      },
      projectSel: "",
      errorModal: {
        open: false,
        msg: ""
      }
    };
  },
  watch: {
    listenErrorMsg: function() {
      if (Store.state.errorMsg) {
        this.errorModal.open = Store.state.errorMsg.open;
        this.errorModal.msg = Store.state.errorMsg.msg;
      }
    }
  },
  computed: {
    listenErrorMsg() {
      return Store.state.errorMsg;
    }
  },
  methods: {
    closeProjectTem() {
      this.projectSpeed.open = false;
    },
    closeError() {
      Store.commit("setErrorMsg", {
        open: false,
        msg: ""
      });
    },
    logout() {
      location.href = "/sharespot-server/public/logout";
    }
  }
};
</script>

<style lang="less" scoped>
.header-info {
  height: 50px;
  line-height: 50px;
  background-color: #3080fe;
  border-bottom: 1px solid #dcdcdc;
  .aside-logo {
    text-align: center;
    display: inline-block;
    background-color: #fff;
    border-bottom: 1px solid #eee;
    width: 239px;
    border-right: 1px solid #ddd;
    height: 49px;
    > .logo {
      height: 42px;
      width: 100%;
      text-align: center;
      display: block;
      line-height: 42px;
      font-size: 18px;
    }
  }
  .name-company {
    font-size: 16px;
    color: #ffffff;
    font-weight: bolder;
    height: 50px;
    .name {
      color: #fff;
      margin-left: 30px;
      cursor: pointer;
    }
  }
  .tip-menu {
    float: right;
    li {
      display: inline-block;
      margin-right: 10px;
      color: #fff;
      cursor: pointer;
      span {
        padding: 5px 15px;
        &:hover {
          background: #1861d5;
        }
      }
    }
  }
  .tool-user {
    padding: 0;
    margin-left: 0;
    vertical-align: top;
    color: #606266;
    float: right;
    .user-card {
      text-align: center;
      width: 90px;
      padding: 0 14px;
      display: inline-block;
      color: #fff;
      height: 40px;
      .pic {
        line-height: 40px;
      }
    }
    .user-nav {
      display: none;
      background-color: #fff;
      text-align: center;
      z-index: 1;
      color: #eee;
      border-bottom-left-radius: 4px;
      border-bottom-right-radius: 4px;
      text-align: center;
      position: absolute;
      color: #9099fe;
      right: 3px;
      width: 100px;
      box-shadow: 0 0 10px #666;
      padding: 10px 0;
      li {
        line-height: 35px;
        height: 35px;
        color: #333;
        cursor: pointer;
        &:hover {
          color: red;
        }
      }
      a {
        color: #333;
        &:hover {
          color: #606266;
        }
      }
    }
    &:hover {
      .user-nav {
        display: block;
      }
    }
  }
  .project-tempalte {
    .content {
      padding: 20px 0 15px;
      text-align: center;
      > div {
        margin-bottom: 15px;
        span {
          width: 60px;
          display: inline-block;
          font-size: 14px;
          color: #666;
        }
        input {
          width: 250px;
          height: 33px;
        }
      }
    }
    .foot-it {
      height: 60px;
      .btn-it {
      }
    }
  }
}
</style>
